<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<#assign base=request.contextPath  />
        	<base id="basePath" href="${base}">

        	<base id="basePath" href="${base}">
        	<link rel="stylesheet" href="${base}/css/demo.css" type="text/css">
        	<link rel="stylesheet" href="${base}/css/zTreeStyle.css" type="text/css">
        	<script type="text/javascript" src="${base}/js/ztree/jquery-1.4.4.min.js"></script>
        	<script type="text/javascript" src="${base}/js/ztree/jquery.ztree.core.js"></script>
        	<script type="text/javascript" src="${base}/js/zhang.js"></script>
        	<script type="text/javascript" src="${base}/js/ztree/jquery.ztree.excheck.js"></script>
        	<script type="text/javascript" src="${base}/js/ztree/jquery.ztree.exedit.js"></script>
		<script src="${base}/js/layui/layui.js"></script>
		<script src="${base}/js/jquery.min.js"></script>
		<link rel="stylesheet" type="text/css" href="${base}/js/layui/css/layui.css"/>
	</head>
	<style type="text/css">
        form{
             padding: 20px;
               }
        .layui-btn-radius{
             border-radius: 10px;
            }
     </style>

	<body>
	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
	  <legend>办理入住</legend>
	</fieldset>
	<div class="demoTable" style="padding:15px;">
             <button class="layui-btn layui-btn-radius" id="btn2" data-method="offset" type="button" style="background-color: #0092EF;">添加办理入住</button>
            <div class="layui-inline layui-form" style="float:right;">
            <div class="layui-input-inline">
                <select name="interest"  id="sech"  lay-search="">
                    <option value="">请选择要搜索的列</option>
                    <option value="name">孕妇姓名</option>
                    <option value="phone">联系方式</option>
                    <option value="weixin">微信</option>
                    <option value="address">家庭住址</option>
                    <option value="nurse">责任护士</option>
                    <option value="nurseryTeacher">育婴师</option>
                    <option value="babyName">宝宝姓名</option>
                    <option value="Prenatal_escort">有无产前陪同</option>
                    <option value="disease">病历史</option>
                    <!--<option value="deposit">押金</option>-->
                    <option value="set_money">定金</option>
                    <option value="person">录入人</option>
                    <option value="special_requirements">有无特殊需求</option>
                </select>
            </div>

        	  <div class="layui-inline">
        	    <input class="layui-input" name="id" id="demoReload" autocomplete="off">
        	  </div>
        	  <button class="layui-btn layui-btn-radius" id="btn1" data-type="reload"  style="background-color: #0092EF;">搜索</button>
           </div>
        </div>
	<table class="layui-hide" id="table_baby" lay-filter="user"></table>
  <script type="text/html" id="barDemo">
          {{#  if(d.orderStatus ==1){ }}
           <a style="Color:red;">该订单已成功</a>
          {{#  } else { }}
             <a class="layui-btn layui-btn-primary layui-btn-xs"   href="javascript:void(0)"  onclick="success1('{{d.id}}')" lay-event="detail" >成功 </a>
          {{#  } }}
      </script>
<script>

layui.use(['form', 'layedit', 'laydate','table','layer'], function(){
  var form = layui.form
  ,$ = layui.jquery
  ,layedit = layui.layedit
  ,laydate = layui.laydate
  ,table = layui.table
  ,layer= layui.layer;
 table.render({
     elem: '#table_baby'
     ,url: '${base}/orderVip/selectOrderVip'//数据接口
     ,toolbar: '#toolbarDemo'
         ,defaultToolbar: ['filter', 'print', 'exports']
     ,cols: [[
     {field:'id', title: 'ID',templet:function(val){
                                   return val.LAY_INDEX
                           },width:70, field: true,align:'center'}
       ,{field:'room_name', title: '房间号',width:90,align:'center'}
       ,{field:'name', title: '孕妇姓名',width:100,align:'center'}
       ,{field:'sex',templet:function(val){
                    			  if(val.sex=="1"){
                                      return "女";
                    			  }else{
                                      return "女";
                    			  }

                              }, title: '性别',width:60,align:'center'}
       ,{field:'birth',templet:function(val){
                        return DateFormat(val.birth);
                     },title: '出生年月',width:120,align:'center'}
       ,{field:'childbirth',templet:function(val){
                                   return DateFormat(val.childbirth);
                                 },title: '实际入住时间',width:120,align:'center'}
          ,{field:'phone', title: '联系方式',width:120,align:'center'}
           ,{field:'weixin', title: '微信',width:100,align:'center'}
       ,{field:'address', title: '家庭住址',width:150,align:'center'}
       ,{field:'mealName',title: '套餐项',width:120,align:'center'}
      // ,{field:'deposit',title: '押金',width:100,align:'center'}
        ,{field:'nurse',title: '责任护士',width:100,align:'center'}
         ,{field:'nurseryTeacher',title: '育婴师',width:100,align:'center'}
          ,{field:'babyName',title: '宝宝姓名',width:100,align:'center'}
           ,{field:'babySex', title: '宝宝性别',width:100,align:'center'}
       ,{field:'setMoney',title: '定金',width:100,align:'center'}
       //,{field:'relay', title: '是否接送',width:80,align:'center'}
       ,{field:'disease',title: '病历史',width:150,align:'center'}
        //,{field:'hospital', title: '计划生产医院',width:150,align:'center'}
        ,{field:'prenatalEscort', title: '有无产前陪同',width:100,align:'center'}
        ,{field:'specialRequirements', title: '有无特殊需求',width:200,align:'center'}
         //,{field:'customerSource',title: '客户渠道',width:120,align:'center'}
          //,{field:'howLong',title: '沟通时长',width:90,align:'center'}
       ,{field:'dateOfTransaction',templet:function(val){
                                return DateFormat(val.dateOfTransaction);
                             }, title: '成交日期',width:120,align:'center'}


       ,{field:'orderStatus',title: '是否成交',templet:function(val){
                                           			  if(val.orderStatus=="1"){
                                                             return "已成功";
                                         			  }else{
                                                             return "未成功";
                                           			  }
                                                  },width:100,align:'center'}
        ,{field:'person',title: '录入人',width:100,align:'center'}
       ,{field: 'right', toolbar: '#barDemo',title: '操作',width:120,align:'center'}
     ]]
    ,id: 'testReload'
    ,page: {
           layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
           ,theme: '#0092EF'
           ,limit:20
         }
    ,height:500

  });
  $('#btn2').on('click', function(){
     var othis = $(this), method = othis.data('method');
     active[method] ? active[method].call(this, othis) : '';
   });
    $('#btn1').on('click', function(){
        var sechLin=$("#sech").val();
           var whereData={};
       });

  var active = {
          	offset: function(othis){
          	  var type = othis.data('type')
          	  ,text = othis.text();
      		  layer.open({
      		  type: 2,
      		  title: '添加订单',
      		  shadeClose:false ,
      		  offset: 't',
              area:['760px','100%'],
      		  content: '${base}/orderVip/order_add',
              success: function (layero, index) {
                    var initHomeId='${InitHomeId}';
                    var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    setTimeout(function(){
                        iframeWin.$("#home_id option[value='${InitHomeId}']").attr("selected", "selected");
                        iframeWin.layui.form.render('select')
                    },200)
                }
      });
     }
    };


//清空搜索框(比如第一次搜索姓名,然后在搜索手机号的时候搜索框是空的)
      layui.form.on('select()', function(data){
       $("#demoReload").val("")
      });


//实现搜索
$('#btn1').on('click', function(){
   var sechLin=$("#sech").val();
   var sechData=$("#demoReload").val();

      var whereData={};
      whereData.lin=sechLin;
      whereData.data=Trim(sechData);
whereData.page=1;
                whereData.limit=10;
              var table = layui.table;
              //表刷新方法
              table.reload('testReload', {
                  url:'${base}/orderVip/selectOrderVip'
                  ,where: whereData //设定异步数据接口的额外参数
              });
  });
    String.prototype.trim = function() {
      return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
    }





});
setTimeout(function(){
var flag='${home_true}';

if(flag=="home_true"){
    $("#btn2").click();
}
},200)

//点击完成提交 点击成功状态的id
function success1(id){
     $.ajax({
        type:"POST",
        url:"${base}/orderVip/update",
        data:{"id":id},
        async:false,
        success:function(data){
        var table = layui.table;
             //表刷新方法
             table.reload('testReload', {
             url: '${base}/orderVip/selectOrderVip'
              ,where: {}, //设定异步数据接口的额外参数
               });
               $(".tk1").hide(200)
                }
     });
   }

//键盘事件
   $("body").bind("keydown",function(e){
       // 兼容FF和IE和Opera
       var theEvent = e || window.event;
       var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
       if (code == 13) {
           //回车执行查询
           $("#btn1").click();
       }
   });

</script>
</body>
</html>
